package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.FlowFormNewDiskStandardDetailDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormNewDiskStandardDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class FlowFormNewDiskStandardDetailConverter {

    public static FlowFormNewDiskStandardDetailDto do2Dto(FlowFormNewDiskStandardDetail domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        return FlowFormNewDiskStandardDetailMapper.INSTANCE.do2Dto(domain);
    }

    public static List<FlowFormNewDiskStandardDetailDto> do2Dto(List<FlowFormNewDiskStandardDetail> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormNewDiskStandardDetailConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormNewDiskStandardDetail dto2Do(FlowFormNewDiskStandardDetailDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        return FlowFormNewDiskStandardDetailMapper.INSTANCE.dto2Do(dto);
    }

    public static List<FlowFormNewDiskStandardDetail> dto2Do(List<FlowFormNewDiskStandardDetailDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormNewDiskStandardDetailConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface FlowFormNewDiskStandardDetailMapper {

        FlowFormNewDiskStandardDetailMapper INSTANCE = Mappers.getMapper(FlowFormNewDiskStandardDetailMapper.class);

        FlowFormNewDiskStandardDetailDto do2Dto(FlowFormNewDiskStandardDetail domain);

        List<FlowFormNewDiskStandardDetailDto> do2Dto(List<FlowFormNewDiskStandardDetail> domain);

        FlowFormNewDiskStandardDetail dto2Do(FlowFormNewDiskStandardDetailDto dto);

        List<FlowFormNewDiskStandardDetail> dto2Do(List<FlowFormNewDiskStandardDetailDto> dto);
    }
}
